package com.raven.play.datalink.common.type;

import lombok.*;
import org.jetbrains.annotations.Range;

/**
 * https://avro.apache.org/docs/1.11.1/specification/#decimal
 */
@Getter
@Setter
@ToString
public class BigDecimalField extends SimpleField {

    /**
     * 最大精度, 即该数字的最大长度
     */
    @Range(from = 0, to = Integer.MAX_VALUE)
    private Integer precision;

    /**
     * 小数部分长度
     * 讲道理, 不能超过 precision 的大小
     */
    @Range(from = 0, to = Integer.MAX_VALUE)
    private Integer scale;

    public BigDecimalField(String name){
        this(name, 32, 16);
    }

    public BigDecimalField(String name, Integer precision, Integer scale) {
        super(name, TypeEnum.BIG_DECIMAL);
        this.precision = precision;
        this.scale = scale;
    }
}